package com.hqyj.serviceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hqyj.mapper.TicketMapper;
import com.hqyj.pojo.Ticket;
import com.hqyj.serviceInf.TicketServiceInf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class TicketServiceImpl implements TicketServiceInf {


    @Autowired
    private TicketMapper ticketMapper;
    //分页查询
    @Override
    public Map<String, Object> selectAll(int pageNum, int pageSize,String ticketname) {
        PageHelper.startPage(pageNum,pageSize);
        List<Ticket> tickets = ticketMapper.selectAll(ticketname);
        PageInfo<Ticket> ticketPageInfo = new PageInfo<>(tickets);
        HashMap<String, Object> map = new HashMap<>();
        map.put("code",200);
        map.put("ticketPageInfo",ticketPageInfo);
        return map;
    }


    @Override
    public int insertTicket(Ticket ticket) {
        return ticketMapper.insertTicket(ticket);
    }
    //单个查询
    @Override
    public Ticket showTicketById(int ticketid) {
        return ticketMapper.showTicketById(ticketid);
    }
    //修改
    @Override
    public int updateTicket(Ticket ticket) {
        return ticketMapper.updateTicket(ticket);
    }
    //删除
    @Override
    public int delateTicket(int ticketid) {
        return ticketMapper.delateTicket(ticketid);
    }
}
